home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 4
/
Precision Software Applications Silver Collection Volume 4 (1993).iso
/
stats
/
eval108.exe
/
EVAL.DOC
< prev
next >
Wrap
Text File
|
1992-07-17
|
14KB
|
374 lines
EVAL V1.08 Copyright (c) 1991-1992 Copy Con Incorporated Page 1
TO PRINT THIS FILE, TYPE "COPY EVAL.DOC PRN" AT THE DOS PROMPT.
OVERVIEW
--------
EVAL is a mathematical expression evaluator, capable of evaluating
virtually any formula, including those with trigonometric functions,
complex numbers, and user-defined variables. Formulas are typed in at
the command line, and the formula and outcome (and optionally the
variable values) are immediately displayed on your screen, or can be
sent to any device or file via standard DOS redirection.
DISCLAIMER
----------
EVAL is distributed on an "AS IS" basis without warranty, expressed or
implied. Considerable testing effort has been expended, but the user
is advised to check the program's suitability before relying on it.
The user assumes full risk as to the results of using this program.
Any liability of the author will be limited exclusively to product
replacement. In no event shall the author be liable for any incidental
or consequential damages arising from the use, or inability to use
this program.
REGISTRATION
------------
The unregistered version of EVAL is freely distributable and fully
functional, and may be used for a 30-day trial period. If you plan to
continue using EVAL after the trial period, you are obligated to pay
the modest registration fee of $20. Registered users will receive the
latest version of EVAL with the "nag" messages removed, along with a
smaller, math-chip version of EVAL. Registration also entitles you to
one free upgrade upon request, and half-priced subsequent upgrades.
All registration information is contained in the REGISTER.TXT file. If
that file is missing, register by sending a check or money order for
$20 in U.S. dollars, drawn on a U.S. bank, to:
Copy Con Incorporated
PO Box 23255
Baltimore MD 21203-5255
Please specify 3.5" or 5.25" diskette. MD residents add 5% sales tax.
We thank you for your support.
EVAL V1.08 Copyright (c) 1991-1992 Copy Con Incorporated Page 2
OPERATION
---------
EVAL is activated from the command line, using the format
EVAL [[~]variable=expression;...] expression [options]
Expressions are mathematical formulas built with the supported
functions, operators, constants and variables.
FUNCTIONS
---------
Following are the functions that EVAL supports:
Function Description
-------- -----------
abs Absolute value
acos Arc cosine
arg Angle of input value in the complex plane
asin Arc sine
atan Arc tangent
ceil Smallest integer not less than input value (rounds up)
conj Complex conjugate of input value
cos Cosine
cosh Hyperbolic cosine
csc Cosecant
ctn Cotangent
cub Cube root
exp E to the power of input value
flr Largest integer not more than input value (rounds down)
frac Fractional part of input value
imag Imaginary part of complex number
int Integer part of input value
ln Natural logarithm
log Natural logarithm (same as LN)
logt Base 10 logarithm
norm Square of the absolute value
rand Random integer between 1 and input value (max 32767)
real Real part of complex number
sec Secant
sgn Sign of input value (positive=1, negative=-1, zero=0)
sin Sine
sinh Hyperbolic sine
sqr Square (x^2)
sqrt Square root
tan Tangent
tanh Hyperbolic tangent
EVAL V1.08 Copyright (c) 1991-1992 Copy Con Incorporated Page 3
FUNCTIONS (continued)
---------------------
Parentheses are optional when using functions; if they are not used,
only the first value following the function will be considered the
argument. For example:
sin pi evaluates to sin(pi)
sin pi/2 evaluates to sin(pi)/2
sin(pi/2) evaluates to sin(pi/2)
Use of functions without parentheses is potentially erroneous, and it
is generally preferable to use parens to indicate function arguments.
OPERATORS
---------
Each operator has a precedence, and operators with higher precedence
are evaluated before operators with lower precedence. Operators with
equal precedence are handled from left to right within a function.
Precedence is indicated by order in the following table (the first
line has the highest precedence):
Operators Description
--------- -----------
( ) Left parenthesis,Right parenthesis
! Unary factorial
+ - Unary sign
^ Exponential
* / % Multiplication,Division,Modulus
+ - Addition,Subtraction
Where it is not ambiguous, multiplication can be indicated by
adjacency: 8(6-4) = 8*(6-4) = 16. Implicit multiplication is
potentially erroneous, and it is generally preferable to use the '*'
symbol to indicate multiplication.
CONSTANTS
---------
EVAL supports numeric constants, and three alphabetic constants, PI,
E, and I. Alphabetic constants cannot directly follow functions; use
"cos pi" or "cos(pi)", not "cospi". Numeric constants need not be
separated from functions; "sin3" is okay.
Numerical constants are entered just as you would ordinarily write
them. They can be preceeded with optional + or - signs. The following
are all valid numerical entries:
6.78 0.678 .678 -678
Blanks are not permitted in numbers; the expression "7 8" would be
evaluated as 7 times 8, not 78.
EVAL V1.08 Copyright (c) 1991-1992 Copy Con Incorporated Page 4
CONSTANTS (continued)
---------------------
Complex numbers can be used as easily as real numbers. Any of EVAL's
functions which are mathematically defined for complex values (like
SIN and EXP) will accept complex arguments. Complex numbers are
entered using the form "x+yi" where "i" is equivalent to the square
root of -1. The following are all valid complex number entries:
3+4i 5.2-3.45i -63i
Alphabetic constants can also be used as easily as real numbers; just
be careful not to string them together with functions, variables, and
other alphabetic constants; instead of "lne+api", use "ln e + a pi",
or "ln(e)+a*pi". "3pi/2" and "4i" are valid, as EVAL can tell where
one constant ends and another begins.
Following are the approximate values of the alphabetic constants:
PI = 3.14159265
E = 2.71828183
I = sqrt(-1)
VARIABLES
---------
The letters A-Z (except for E and I) are set aside as user-definable
variables. Variables have a default value of 0, and are assigned
values using the equals sign. For example:
EVAL a=pi;b=cub(8);b*cos(a)
will assign a value of PI to A, a value of 2 to B, and will print out
the value of B times the cosine of A. As with alphabetic constants,
variables cannot directly follow functions; use a space delimiter, or
parentheses as above.
OPTIONS
-------
Options must be in the form "OPTION:value", as in "a:g" or "d:5". Case
is not important. Separate options with spaces.
Option Description
------ -----------
A Angular unit - whether angles will be expressed as degrees,
radians, or grads. Use the first letter of the unit, as in
"a:d". By default, angular units are expressed as radians.
D Significant digits - the number of significant digits shown in
the expression outcome. Range is 1 thru 18; the default is 10.
EVAL V1.08 Copyright (c) 1991-1992 Copy Con Incorporated Page 5
OPTIONS (continued)
-------------------
Option Description
------ -----------
R[P] Recursions - number of times the formula will repeat itself,
starting at the tilde (~) character. For example,
EVAL a=0 ; ~a=a+1 ; a v:n r:20
will parse the entire formula, then repeat from the tilde
character a total of twenty times. If the 'rp:' option is
used instead, EVAL will wait after each screen for a keypress.
Range is 0 thru 2147483646. Default is 0.
V Show variables - whether variables and their values will be
displayed as they are assigned values. If this option is set
to F, the formulas will also be shown. Default is Y.
ERROR MESSAGES
--------------
Following are error messages you may come across, along with their
descriptions and corresponding DOS errorlevels:
Level Message & Description
----- ---------------------
1 Invalid input - you have attempted to use an unsupported
option, or you have exceeded an option's range.
2 Invalid function '(function)' - you have attempted to use an
unsupported function. If it's a common function, let us know,
and we will add it.
3 Ctrl-Break pressed - self-explanatory. No message is shown.
4 Expression too complex - your formula has 128 or more
constants, or more than 255 combined constants, functions, and
operators.
5 Invalid operator '(op)' - you have attempted to use an
unsupported operator. If it's a common operator, let us know,
and we will add it.
6 Mixmatched parentheses - there were an uneven amount of
parentheses, or a right parenthesis was encountered before its
matching left paren.
7 Invalid use of functions - functions cannot be directly
followed by an operator (unless the operator is a "+" or "-"
indicating the sign of the value that follows).
EVAL V1.08 Copyright (c) 1991-1992 Copy Con Incorporated Page 6
ERROR MESSAGES (continued)
--------------------------
Level Message & Description
----- ---------------------
8 Invalid use of operators - operators cannot be directly
followed by other operators (unless the second operator is a
"+" or "-" indicating the sign of the value that follows).
9 Invalid variable '(variable)' - an attempt was made to assign a
value to a constant or a non-variable.
10 Division by zero - a denominator in your formula has a value of
zero, which is mathematically undefined.
11 Argument domain/range - a function in the formula cannot
evaluate its input value, as the value is outside of the
function's range.
12 Argument singularity - formula would result in a singularity.
13 Overflow - the formula evaluates to a result greater than the
maximum allowed.
14 Underflow - the formula evaluates to a result less than the
minimum allowed.
15 Total significance loss - formula would produce a result with
a total loss of significant digits.
EXAMPLES
--------
EVAL sqrt3 d:4
displays the square root of 3, limited to 4 significant digits.
( sqrt3 evaluates to sqrt(3) )
EVAL a=pi ; b=cub 8 ; b*cos(a)
assigns a value of PI to A, a value of 2 to B, and displays the
value of B times the cosine of A. The values of A and B are also
displayed. (The spaces around the semicolons are not required)
EVAL x=1/10;asin(5x) a:d v:n
assigns a value of .1 to X, and displays the arcsine of quantity
5 times X, expressed in degrees. The value of X is not displayed.
( 5x is equivalent to 5*x )
EVAL (2+4i)/(6-8i)
displays the result of the first complex number divided by the
second complex number.
EVAL V1.08 Copyright (c) 1991-1992 Copy Con Incorporated Page 7
EXAMPLES (continued)
--------------------
EVAL 3*4!
displays the result of 4 factorial, times 3. Since factorials are
higher in precedence than multiplication, use "EVAL (3*4)!" to
show 3 times 4 quantity, factorial.
EVAL z=2+3i ; ~z=log z ; z v:n d:18 rp:120
sets z equal to complex number 2+3i, sets z to the logarithm of
its current value, displays the new value to 18 significant
digits, then repeats from the logarithm step 120 times, pausing
after each screen.
EVAL a=1 ; ~b=b+1/a ; a=a+2 ; b=b-1/a ; a=a+2 ; 4b v:n d:18 r:6000
assigns 1 to a, adds 1/a to b, adds 2 to a, subtracts 1/a from b,
adds 2 more to a, prints 4*b to 18 significant digits, then
repeats the formula from the ~ symbol 6000 times. Incidentally,
this is a popular method of calculating the value of PI. (Well,
yeah, I suppose you could just use EVAL PI, if you're in a hurry
or something.... :^)
CORRESPONDENCE
--------------
If you have questions, comments, suggestions, bug reports, et cetera,
feel free to contact us by one of the following methods:
1: By modem at The Programmer's Corner (301-596-7692 or 410-995-6873).
Send a message to user number 3000, and check back in a couple of
work days for a reply.
2: By U.S. Mail at the address given on the first page. If you would
like a reply, please include a self-addressed, stamped envelope.
We look forward to hearing from you.